package com.probos.bosnatuur.monitor;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
// import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TabHost;

public class ElementTab extends TabActivity {
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.element_tab);

    	Bundle extras = getIntent().getExtras();
    	Long project_id = null;
    	Long element_id = null;
//    	String strTitle = "";
    	String strLocation = "";
    	Long new_id = null;

    	if (extras != null) {
    		if (extras.containsKey(ProjectDbAdapter.KEY_ROWID))   element_id = extras.getLong(ProjectDbAdapter.KEY_ROWID);
        	if (extras.containsKey(ProjectDbAdapter.KEY_PROJECT)) project_id = extras.getLong(ProjectDbAdapter.KEY_PROJECT);
    		if (extras.containsKey(ProjectDbAdapter.KEY_SHAPE))   strLocation = extras.getString(ProjectDbAdapter.KEY_SHAPE);            	
    		if (extras.containsKey("new_id")) new_id = extras.getLong("new_id");
	    }

	    // Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Reusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)	    
	    intent = new Intent().setClass(this, ElementEdit.class);
	    
	    if (project_id != null) intent.putExtra(ProjectDbAdapter.KEY_PROJECT, project_id);
	    if (element_id != null) intent.putExtra(ProjectDbAdapter.KEY_ROWID, element_id);
	    if (new_id != null) intent.putExtra("new_id", new_id);	    
	    intent.putExtra(ProjectDbAdapter.KEY_SHAPE, strLocation);
	    	    
	    // Initialize a TabSpec for each tab and add it to the TabHost
		// .setIndicator("Algemeen", res.getDrawable(R.drawable.ic_tab_elements))
		// .setIndicator("Kaart", res.getDrawable(R.drawable.ic_tab_elements))
	    spec = tabHost.newTabSpec("algemeen").setIndicator("Algemeen").setContent(intent);
	    tabHost.addTab(spec);

	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, ElementCultuurhistorie.class);
	    
	    if (project_id != null) intent.putExtra(ProjectDbAdapter.KEY_PROJECT, project_id);
	    if (element_id != null) intent.putExtra(ProjectDbAdapter.KEY_ROWID, element_id);
	    if (new_id != null) intent.putExtra("new_id", new_id);	    
	    
	    spec = tabHost.newTabSpec("cultuurhistorie").setIndicator("Cultuurhistorie").setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, ElementPictures.class);
	    
	    if (project_id != null) intent.putExtra(ProjectDbAdapter.KEY_PROJECT, project_id);
	    if (element_id != null) intent.putExtra(ProjectDbAdapter.KEY_ROWID, element_id);
	    if (new_id != null) intent.putExtra("new_id", new_id);
	    
	    spec = tabHost.newTabSpec("pictures").setIndicator("Foto's").setContent(intent);
	    tabHost.addTab(spec);
	    
	    tabHost.setCurrentTab(0);
	}
		
}
